import 'dart:io';

class SmartHome {
  bool lightsOn = false;
  int thermostat = 20;
  bool securityArmed = false;
  
  static const int minTemp = 15;
  static const int maxTemp = 30;

  void toggleLights() {
    lightsOn = !lightsOn;
    print("\nLights are now: ${lightsOn ? 'ON' : 'OFF'}");
  }

  void setThermostat(int temp) {
    if (temp >= minTemp && temp <= maxTemp) {
      thermostat = temp;
      print("\nThermostat set to: $thermostat°C");
    } else {
      print("\nTemperature out of range!");
    }
  }

  void toggleSecurity() {
    securityArmed = !securityArmed;
    print("\nSecurity system is now: ${securityArmed ? 'ARMED' : 'DISARMED'}");
  }

  void showStatus() {
    String tempStatus = thermostat % 3 == 0 && thermostat % 5 == 0
        ? "Perfect Day"
        : thermostat % 3 == 0
            ? "Cool Day"
            : thermostat % 5 == 0
                ? "Warm Day"
                : "$thermostat°C";
    print("\nSystem Status: Lights: ${lightsOn ? 'ON' : 'OFF'}, Temperature: $tempStatus, Security: ${securityArmed ? 'ARMED' : 'DISARMED'}");
  }
}

void main() {
  SmartHome home = SmartHome();
  while (true) {
    print("\n1. Toggle Lights\n2. Set Thermostat\n3. Toggle Security\n4. View Status\n5. Exit");
    stdout.write("Choose an option: ");
    String? choice = stdin.readLineSync();
    
    switch (choice) {
      case '1':
        home.toggleLights();
        break;
      case '2':
        stdout.write("Enter temperature (between 15-30): ");
        int? temp = int.tryParse(stdin.readLineSync()!);
        if (temp != null) home.setThermostat(temp);
        break;
      case '3':
        home.toggleSecurity();
        break;
      case '4':
        home.showStatus();
        break;
      case '5':
        print("\nProgram exited.");
        return;
      default:
        print("\nInvalid option")
    }
  }
}